package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.controller.getRFC;

import java.sql.ResultSet;
import java.sql.SQLException;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.controller.database.DatabaseConnection;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.model.RFC;

public class GetRFCFromDB {

	public RFC getRFC(int id) throws SQLException{
		String query;
		RFC rfc = new RFC(""+id);
		DatabaseConnection db = new DatabaseConnection();
		query = "SELECT * FROM `CMS_RFC` where "+ RFC.TC_ID + "='" + id + "'"; 
		ResultSet rs = db.query(query);
		rs.next();
		rfc.setAffected_Infrastructure_Components(rs.getString(RFC.TC_AFFECTEDINFRASTRUCTURE));
		rfc.setAffected_Services(rs.getString(RFC.TC_AFFECTEDSERVICES));
		rfc.setApproval_charge_Person(rs.getString(RFC.TC_APPROVALPERSON));
		rfc.setBenefits(rs.getString(RFC.TC_BENEFITS));
		rfc.setChange_Owner(rs.getString(RFC.TC_CHANGEOWNER));
		rfc.setCosts(rs.getString(RFC.TC_COSTS));
		rfc.setDate_Approval_Recjection(rs.getString(RFC.TC_DATEOFREJECTIONORAPPROVAL));
		rfc.setDetailed_Description(rs.getString(RFC.TC_DETAILEDDESCRIPTION));
		rfc.setPriority(rs.getString(RFC.TC_PRIORITY));
		rfc.setReason_for_Change(rs.getString(RFC.TC_REASONFORCHANGE));
		rfc.setReason_of_Rejecting(rs.getString(RFC.TC_REASONOFREJECTING));
		rfc.setRfc_Initiator(rs.getString(RFC.TC_RFCINITIATOR));
		rfc.setRisks(rs.getString(RFC.TC_RISKS));
		rfc.setStatus(rs.getString(RFC.TC_Status));
		rfc.setSubmission_Date(rs.getString(RFC.TC_SUBMISSIONDATE));
		rfc.setSummary(rs.getString(RFC.TC_SUMMARY));
	
		
		return rfc;
	}

}
